<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/summernote/summernote.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/summernote/summernote-bs3.css}" rel="stylesheet"/>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-huodong-add">
			<input id="huiZhangId" name="huiZhangId" class="form-control" th:value="${huiZhangId}" type="hidden">
			<div class="form-group">	
				<label class="col-sm-3 control-label">活动名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">活动简介：</label>
				<div class="col-sm-8">
					<input id="jianjie" name="jianjie" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">活动时间：</label>
				<div class="col-sm-8">
					<input id="huoDongTime" name="huoDongTime" class="time-input" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">报名人数：</label>
				<div class="col-sm-8">
					<input id="number" name="number" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">报名截止时间：</label>
				<div class="col-sm-8">
					<input id="endTime" name="endTime" class="time-input" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="status" name="status">
						<label class="onoffswitch-label" for="status">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">活动内容介绍：</label>
				<div class="col-sm-8">
					<input id="neirong" name="neirong" type="hidden">
					<div class="summernote" id="summernote"></div>

				</div>
			</div>


		</form>
	</div>
    <div th:include="include::footer"></div>
	<script th:src="@{/ajax/libs/summernote/summernote.min.js}"></script>
	<script th:src="@{/ajax/libs/summernote/summernote-zh-CN.js}"></script>
    <script type="text/javascript">
		var prefix = ctx + "system/huodong";

		/**
		 * 最新富文本编辑器中华的图片上传功能
		 * 图片显示但是无法保存
		 */
		$('.summernote').summernote({
			height: '220px',
			lang: 'zh-CN',
			onImageUpload:function (files,editor,$editable) {
				var $files = $(files);
				$files.each(function () {
					var file = this;
					var data = new FormData();
					data.append("file",file);
					$.ajax({
						data:data,
						url:ctx + "common/upload",
						cacne:false,
						contentType:false,
						processData:false,
						success:function (response) {
							var imageUrl = response.msg;
							editor.insertImage($editable,ctx+"profile/"+imageUrl,response.fileName);
						}
					})
				})
			}

		});

/*		//调用富文本编辑
		$(document).ready(function() {
			var $summernote = $('#summernote').summernote({
				height: 300,
				minHeight: null,
				maxHeight: null,
				focus: true,
				//调用图片上传
				callbacks: {
					onImageUpload: function (files) {
						sendFile($summernote, files[0]);
					}
				}
			});

			//ajax上传图片
			function sendFile($summernote, file) {
				var formData = new FormData();
				formData.append("file", file);
				$.ajax({
					url: "common/upload",//路径是你控制器中上传图片的方法，下面controller里面我会写到
					data: formData,
					cache: false,
					contentType: false,
					processData: false,
					type: 'POST',
					success: function (data) {
						$summernote.summernote('insertImage', data, function ($image) {
							$image.attr('src', data);
						});
					}
				});
			}
		});*/





		$("#form-huodong-add").validate({
			ignore:".note-image-input,.note-group-select-from-files",
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
				var sHTML = $('.summernote').summernote('code');
				$("#neirong").val(sHTML);
	            $.operate.save(prefix + "/add", $('#form-huodong-add').serialize());
	        }
	    }
	</script>
</body>
</html>
